from p4utils.mininetlib.network_API import NetworkAPI

net = NetworkAPI()

# Network general options
net.setLogLevel('info')
net.execScript('python routing-controller.py', reboot=True)

# Network definition
net.addP4Switch('s1')
net.addP4Switch('s2')
net.addP4Switch('s3')
net.addP4Switch('s4')
net.addP4Switch('s5')
net.addP4Switch('s6')
net.addP4Switch('s7')
net.addP4Switch('s8')
net.addP4Switch('s9')
net.addP4Switch('s10')
net.addP4Switch('s11')
net.addP4Switch('s12')
net.addP4Switch('s13')
net.addP4Switch('s14')
net.addP4Switch('s15')
net.addP4Switch('s16')
net.addP4Switch('s17')
net.addP4Switch('s18')
net.addP4Switch('s19')
net.addP4Switch('s20')
net.setP4SourceAll('p4src/loadbalancer.p4')

net.addHost('h1')
net.addHost('h2')
net.addHost('h3')
net.addHost('h4')
net.addHost('h5')
net.addHost('h6')
net.addHost('h7')
net.addHost('h8')
net.addHost('h9')
net.addHost('h10')
net.addHost('h11')
net.addHost('h12')
net.addHost('h13')
net.addHost('h14')
net.addHost('h15')
net.addHost('h16')

net.addLink("h1", "s1")
net.addLink("h2", "s1")
net.addLink("h3", "s2")
net.addLink("h4", "s2")
net.addLink("s1", "s9")
net.addLink("s1", "s10")
net.addLink("s2", "s9")
net.addLink("s2", "s10")
net.addLink("s9", "s17")
net.addLink("s9", "s18")
net.addLink("s10", "s19")
net.addLink("s10", "s20")
net.addLink("h5", "s3")
net.addLink("h6", "s3")
net.addLink("h7", "s4")
net.addLink("h8", "s4")
net.addLink("s3", "s11")
net.addLink("s3", "s12")
net.addLink("s4", "s11")
net.addLink("s4", "s12")
net.addLink("s11", "s17")
net.addLink("s11", "s18")
net.addLink("s12", "s19")
net.addLink("s12", "s20")
net.addLink("h9", "s5")
net.addLink("h10", "s5")
net.addLink("h11", "s6")
net.addLink("h12", "s6")
net.addLink("s5", "s13")
net.addLink("s5", "s14")
net.addLink("s6", "s13")
net.addLink("s6", "s14")
net.addLink("s13", "s17")
net.addLink("s13", "s18")
net.addLink("s14", "s19")
net.addLink("s14", "s20")
net.addLink("h13", "s7")
net.addLink("h14", "s7")
net.addLink("h15", "s8")
net.addLink("h16", "s8")
net.addLink("s7", "s15")
net.addLink("s7", "s16")
net.addLink("s8", "s15")
net.addLink("s8", "s16")
net.addLink("s15", "s17")
net.addLink("s15", "s18")
net.addLink("s16", "s19")
net.addLink("s16", "s20")
net.setBwAll(10)

# Assignment strategy
net.l3()

# Nodes general options
net.enablePcapDumpAll()
net.enableLogAll()
net.enableCli()
net.startNetwork()